'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const deleteEmpty = require('delete-empty');
const gulp_1 = require('gulp');
const clean = require('gulp-clean');
const config_1 = require('../config');
/**
 * Cleans the build output assets from the packages folders
 */
function cleanOutput() {
  const files = config_1.sources.map(source => [
    `${source}/**/*.js`,
    `${source}/**/*.d.ts`,
    `${source}/**/*.js.map`,
    `${source}/**/*.d.ts.map`,
  ]);
  return gulp_1
    .src(files.reduce((a, b) => a.concat(b), []), {
      read: false,
    })
    .pipe(clean());
}
/**
 * Cleans empty dirs
 */
function cleanDirs(done) {
  config_1.sources.forEach(source => deleteEmpty.sync(`${source}/`));
  done();
}
gulp_1.task('clean:output', cleanOutput);
gulp_1.task('clean:dirs', cleanDirs);
gulp_1.task('clean:bundle', gulp_1.series('clean:output', 'clean:dirs'));
